﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using MySQL.Db;
using NLog;

namespace Gollie.Payment.Targetpay
{
	public class IDealHandler : PaymentHandler
	{
		public IDealHandler(string transactionId, bool check)
			: base(transactionId, check)
		{
		}

		protected override bool IsPayedConfirmed()
		{
			logger.Debug("Initiating check...");

			IDealCheck idealCheck = new IDealCheck(transactionId);

			if (idealCheck.Error)
			{
				throw new Exception(idealCheck.ErrorMessage);
			}

			return idealCheck.Payed;
		}


/*
		private void InsertMutation(int userId, decimal amount)
		{
			CommonQueries.InsertSaldoMutation(userId, amount, 2, 0);
		}

		private void SendConfirmationMail(decimal amount, ResultSet resultSet)
		{
			Userinfo userInfo = new Userinfo(resultSet, false);

			MailArguments mailArgs = MailArguments.MailArgs;
			mailArgs.Clear();

			LogWriter.Write("iDEAL transaction successful. User: " + userInfo.FullName + ", amount: " + ObjectFormatter.GetCurrencyString(amount));

			mailArgs["{oldsaldo}"] = ObjectFormatter.GetCurrencyString(userInfo.Saldo - amount);
			mailArgs["{newsaldo}"] = ObjectFormatter.GetCurrencyString(userInfo.Saldo);
			mailArgs["{aanhef}"] = userInfo.MailAanhef;
			mailArgs["{username}"] = userInfo.Gebruikersnaam;
			mailArgs["{amount}"] = ObjectFormatter.GetCurrencyString(amount);
			mailArgs["{reason}"] = "storting via " + (this.paymentType == PaymentType.Ideal ? "iDEAL" : "telefoon");

			EMail email = MailCache.GetMail("balancechanged");
			email.Bcc = true;
			email.Recipients = userInfo.Email;

			email.QueueSingle();
		}
 */
	}
}